<template>
	<view class="wf-box" :style="{ paddingTop: totalheight }">
		<HeadNav titleName="历史消息" :topheight="navBarHeight"></HeadNav>
		
		<!-- :style="{ paddingTop: navBarHeight }" -->
		<view class="chat-main">
				<view class="chat-um" v-for="(item,index) in msgList" @click="jumpRoom(index)">
					<view class="um-avatar">
						<image src="../../static/img/demo-01.png"></image>
					</view>
					<view class="um-info">
						<view class="info-nt">
							<view class="info-name line-1">{{ item.sendNickName }}</view>
							<view class="info-time">{{ item.sendTime }}</view>
						</view>
						<view class="info-new line-1">{{ item.content }}</view>
					</view>
				</view>
		</view>

	</view>

</template>

<script>
	import { groupHistoryApi } from '@/api/api.js'
	import HeadNav from "@/components/HeadNav"
	import navBarMixin from '@/mixin/navBarMixin.js'
	export default {
		data() {
			return {
				
				groupId: '',
				msgList: ''
			}
		},
		mixins: [navBarMixin],
		components: {
			HeadNav
		},
		methods: {
			back() {
				uni.navigateBack()
			},
			
			async searchHistoryMsg(id) {
				const res = await groupHistoryApi({
					groupId: id,
					page: 1,
					size: 20
				})
				this.msgList = res.data
			},
			
			jumpRoom(index) {
				uni.navigateTo({
					// url: '/pages/chat/room?chatIdx=' + index
					url: '/pages/chat/chat'
				})
			},

		},
		mounted() {},

		onLoad(options) {
			this.groupId  = options.id
			this.searchHistoryMsg(options.id)
			
			this.opmillHeight = uni.getStorageSync('statusHeight') + uni.upx2px(96) + 'px'
			
		},

	}
</script>

<style lang="scss" scoped>
	body {
		background: #fff;
	}

	.wf-box {
		position: relative;
		overflow: hidden;
	}

	.head {
		position: fixed;
		top: 0;
		z-index: 1;
		width: 100%;
		height: 96rpx;
		background: #fff;
		
		.back {
			image {
				width: 20rpx;
				height: 37rpx;
			}
		}
		
		.head-np {
			display: flex;
			justify-content: space-between;
			align-items: center;
			width: 100%;
			height: 96rpx;
			padding: 0 30rpx;
			box-sizing: border-box;
		
			.title {
				font-size: 36rpx;
				font-weight: bold;
			}
		}

		.head-title {
			margin: 0 auto;
			font-size: 36rpx;
			font-weight: bold;
			line-height: 96rpx;
			text-align: center;
		}

		.head-opt {
			position: absolute;
			right: 30rpx;
			bottom: 28rpx;
			display: flex;
			align-items: center;

			.head-search {
				margin-right: 40rpx;
			}

			.head-icon {
				width: 40rpx;
				height: 40rpx;
				display: block;
			}

			.head-add {
				position: relative;

			}

		}
	}

	.chat-main {
		padding: 0 30rpx;
		height: calc(100vh - 48px);
		// margin-top: 96rpx;
		background: #f8f8f8;
		overflow: auto;

		.chat-um {
			display: flex;
			align-items: center;

			// padding: 30rpx 0;
			.um-avatar {
				image {
					display: block;
					width: 80rpx;
					height: 80rpx;
				}
			}

			.um-info {
				flex: 1;
				margin-left: 20rpx;
				padding: 30rpx 0;
				border-bottom: 2rpx solid #eee;
				overflow: hidden;

				.info-nt {
					display: flex;

					.info-name {
						flex: 1;
						padding-right: 40rpx;
						font-size: 28rpx;
						color: #333;
					}

					.info-time {
						margin-left: auto;
						font-size: 24rpx;
						color: #999999;
					}
				}

				.info-new {
					margin-top: 8rpx;
					font-size: 24rpx;
					color: #999;
				}
			}
		}
	}


	.operate-list {
		position: absolute;
		top: 0;
		width: 100%;
		min-height: 100%;
		background: transparent;

		.oper-mil {
			position: fixed;
			// top: 96rpx;
			right: 26rpx;
			width: 220rpx;

			// height: 276rpx;
			// background: red;
			.operate-nbox {
				width: 100%;
				height: 100%;
				padding: 12rpx 0 0;
				background: url('../../static/img/chat-03.png') no-repeat;
				background-size: 100% 100%;
				box-sizing: border-box;

				.oper-im {
					padding: 0 30rpx;

					.oper-im-bwarp {
						padding: 15rpx 0;
						display: flex;
						// justify-content: space-between;
					}

					image {
						width: 48rpx;
						height: 48rpx;
					}

					text {
						margin-left: 16rpx;
						color: #fff;
						font-size: 24rpx;
					}
				}


			}
		}
	}
</style>